package chd.edu.train.business.controller.admin;

import chd.edu.train.common.context.LoginMemberContext;
import chd.edu.train.common.resp.CommonResp;
import chd.edu.train.common.resp.PageResp;
import chd.edu.train.business.req.DailyTrainSeatQueryReq;
import chd.edu.train.business.req.DailyTrainSeatSaveReq;
import chd.edu.train.business.resp.DailyTrainSeatQueryResp;
import chd.edu.train.business.service.DailyTrainSeatService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * @author Zhang Chaoliang
 * create 2023
 */
@RestController
@RequestMapping("/admin/daily-train-seat")
public class DailyTrainSeatAdminController {

    @Resource
    private DailyTrainSeatService dailyTrainSeatService;

    /**
     * 保存/修改编辑信息
     * @param req
     * @return
     */
    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody DailyTrainSeatSaveReq req){
        dailyTrainSeatService.save(req);

        return new CommonResp<>();
    }

    /**
     * 保存信息
     * @param req
     * @return
     */
    @GetMapping("/query-list")
    public CommonResp<PageResp<DailyTrainSeatQueryResp>> queryList(@Valid DailyTrainSeatQueryReq req){
        PageResp<DailyTrainSeatQueryResp> list = dailyTrainSeatService.queryList(req);

        return new CommonResp<>(list);
    }

    /**
     * 删除信息
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id){
        dailyTrainSeatService.delete(id);

        return new CommonResp<>();
    }

}
